package com.aaa.javaweb.dao.impl;

import com.aaa.javaweb.dao.GeRenDao;
import com.aaa.javaweb.entity.GeRen;
import com.aaa.javaweb.entity.Grxx;
import com.aaa.javaweb.until.JDBCUntil;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class GeRenDaoImpl implements GeRenDao {
    @Override
    public List<Map> selectGr(String id) {
        String sql="select t_staff.id,t_staff.imgpath,t_staff.sname,t_staff.rzdate,t_staff.tel,t_staff.idcard,t_staff.address,t_departtable.dname from t_staff left JOIN t_departtable on t_staff.deptid=t_departtable.id where t_staff.id=?";
        return JDBCUntil.selectMap(sql,id);
    }

    @Override
    public int insertgeren(GeRen geRen) {
        String sql="update t_staff set tel=?,address=? where id=?";
        return JDBCUntil.Updateout(sql,geRen.getTel(),geRen.getAddress(),geRen.getId());
    }

    @Override
    public int updmima(GeRen geRen) {
        String sql="update t_staff set spwd=? where id=?";
        return JDBCUntil.Updateout(sql,geRen.getPwd(),geRen.getId());
    }

    @Override
    public List<Map> selectku(String kid) {
        String sql="select * from t_user where id=?";

        return JDBCUntil.selectMap(sql,kid);
    }

    @Override
    public int updkehuxx(Grxx grxx) {
        String sql="update t_user set  name=?,idcard=? where id=?";
        return JDBCUntil.Updateout(sql,grxx.getName(),grxx.getIdcard(),grxx.getId());
    }
}
